package com.bwie.controller;

import com.bwie.StoreApplication;
import com.bwie.common.constants.JwtConstants;
import com.bwie.common.constants.TokenConstants;
import com.bwie.common.domain.Store;
import com.bwie.common.domain.User;
import com.bwie.common.domain.request.StoreRequest;
import com.bwie.common.redis.RedisCache;
import com.bwie.common.result.Result;
import com.bwie.service.StoreService;
import com.bwie.service.UserService;
import org.apache.commons.io.output.TaggedOutputStream;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Author：ShenJiaFeng
 * @Package：com.bwie.controller
 * @Project：zg6_week11
 * @name：StoreController
 * @Date：2024/4/25 10:29
 */
@RestController
@RequestMapping("/store")
public class StoreController {
    @Autowired
    private StoreService storeService;

    @Autowired
    private HttpServletRequest request;

    @Autowired
    private UserService userService;


    @Autowired
    private RedisCache redisCache;

    /**
     * 门店信息
     * @param storeRequest
     * @return
     */
    @PostMapping("/list")
    public Result<List<Store>> list(@RequestBody StoreRequest storeRequest){
        return storeService.storeList(storeRequest);
    }

    @PostMapping("/fastUpd")
    public Result fastUpd(@RequestParam("file") MultipartFile multipartFile){
        return storeService.fastUpd(multipartFile);
    }
    /**
     * 新增
     * @param store
     * @return
     */
    @PostMapping("/addStore")
    public Result<Store> addStore(@RequestBody Store store){
        return storeService.addStore(store);
    }


//    @PostMapping("/userInfo")
//    public Result<List<User>> userInfo(){
//        Result<List<User>> listResult = storeService.userList();
//        List<User> data = listResult.getData();
//        return Result.success(data);
//    }

    @PostMapping("/userInfo")
    public Result<User> findByUser(){
        User byId = userService.getById(1);
        return Result.success(byId);
    }

}
